<script setup>
  import { ref, watch } from "vue";
  const count = ref(0);
  // 1. 监听一个响应式数据
  // watch(数据, 改变后回调函数)
  watch(count, () => {
    console.log("count改变了");
  });
  // 2s改变数据
  setTimeout(() => {
    count.value++;
  }, 2000);

  const add=()=>{
    count.value++
  }
</script>

<template>
  <p>计数器：{{ count }}</p>
   <button @click="add">add</button>
</template>